package com.hakim.wfb.platform.controller;

import com.hakim.wfb.customer.params.order.GetOrderListParameter;
import com.hakim.wfb.customer.result.order.OrderListView;
import com.hakim.wfb.customer.service.OrderService;
import com.hkfs.fundamental.api.data.ListResultEx;
import com.hkfs.fundamental.api.params.SessionIdentity;
import com.hkfs.fundamental.session.SessionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by lenovo on 2017/7/15.
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;


    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public ListResultEx<OrderListView> list(GetOrderListParameter param, HttpServletRequest request) {
        SessionHandler sessionHandler = new SessionHandler();
        SessionIdentity sessionIdentity = sessionHandler.getSessionIdentity(request, SessionIdentity.class);
        String userid = sessionIdentity.getUuid();
        String tel = sessionIdentity.getPhone();
        param.setOlUser(userid);
        param.setSessionIdentity(sessionIdentity);
        param.setRequestOffset((param.getPageNo() - 1) * param.getPageSize());
        return orderService.list(param);
    }

}
